﻿using DependencyParse.Library;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.IO;

namespace Dependency.Library.Test
{
    using Microsoft.Practices.Unity;
    
    /// <summary>
    ///This is a test class for AssemblyHelperTest and is intended
    ///to contain all AssemblyHelperTest Unit Tests
    ///</summary>
    [TestClass()]
    public class AssemblyHelperTest
    {
        /// <summary>
        ///A test for LoadInterfaces
        ///</summary>
        [TestMethod()]
        public void LoadAssembly_Test()
        {
            string assemblyPath = @"c:\Projects\TestAssemblies\Reservation.Business.dll"; // TODO: Initialize to an appropriate value
            var actual = AssemblyHelper.Load(assemblyPath);

        }

        [TestMethod()]
        [ExpectedException(typeof(FileNotFoundException))]
        public void LoadAssembly_Test1()
        {
            string assemblyPath = @"Reservation.Business.dll"; // TODO: Initialize to an appropriate value
            var actual = AssemblyHelper.Load(assemblyPath);

        }

        interface ITest
        {
            string Name { get; set; }
        }

        interface ITest2
        {
            string Name { get; set; }
        }

        class Test : ITest
        {
            #region ITest Members

            public string Name
            {
                get;
                set;
            }

            #endregion

            [Dependency]
            public ITest2 Test2 { get; set; }
        }


        [TestMethod]
        public void LoadTypeInterfaces_Test()
        {
            var list = AssemblyHelper.LoadImplementInterfaces(typeof(Test));

            Assert.AreEqual(1, list.Count);

        }

        [TestMethod]
        public void LoadDependencyInterfaces_Test()
        {
            var list = AssemblyHelper.LoadReferencedDependencyInterfaces(typeof(Test));

            Assert.AreEqual(1, list.Count);
        }

        [TestMethod]
        public void LoadFilesFromDiectories_Test()
        {
            var files = Directory.GetFiles(@"c:\Projects\TestAssemblies\", "*.dll");

            foreach (var f in files)
            { 

            }
        }
    }
}
